' the cosine is infinety function, so i used the For from 2 to a big number
' you can change this number but not so big that make the function slow, and not lower than 20
' the number should be even number (2,4,6,8,10,12,14,16,18,20....)
For i = 2 To 150 Step 2
Upper = Number ^ i
Lower = Factorial(i)
PlusMinus = Not (PlusMinus)
If PlusMinus = True Then
Cosine = Cosine - (Upper / Lower)
ElseIf PlusMinus = False Then
Cosine = Cosine + (Upper / Lower)
End If
Next
End Function
Private Function Cosine2(Number As Double) As Double
' Pi
'Cos(x) = Sin(x + ---- )
' 2
Dim Pi: Pi = "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270192852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133055305488204665213841469519415116094330572703657595919530921861173817326117931051185480744623799627495673518857527248912279381830119491298336733624406566430"